<?php
include 'checkLogin.php';
include 'db/li.php';

@$type = $_REQUEST['type'];

if($type == "worker"){
	@$workers = dbSelectAll('select worker.id as wId,imgUrl,worker.name as wName,age,sex,phone,idCard,location,role.name as rName,role.id as rId from worker join role on worker.roleId=role.id');
	
	if(empty($workers)){
		die(json_encode(array("status"=>false,'info'=>'获取数据失败')));
	}
	
	echo json_encode(array('status'=>true,'workers'=>$workers));
}
if($type == "role"){
	@$roles = dbSelectAll('select id,name from role');
	
	if(empty($roles)){
		die(json_encode(array("status"=>false,'info'=>'获取数据失败')));
	}
	
	echo json_encode(array('status'=>true,'roles'=>$roles));
}